Fix issues related to git updates
authorYehuda Katz + Carl Lerche <engineering@tilde.io>
Fri, 15 Aug 2014 00:05:01 +0000 (17:05 -0700)
committerTim Carey-Smith <tim@spork.in>
Fri, 15 Aug 2014 00:05:01 +0000 (17:05 -0700)
We observed that after updating the git repo in a test, unless we waited
for 1s, we got intermittent cases where a subsequent update of the git
source would not pick up the changes.

We observed this both with the git CLI and the branch using libgit2.
There may be a better solution, but we did not find it.

tests/test_cargo_compile_git_deps.rs

index 107c6aa05de4cff4eb2de5b8360224ec466499d7..d20bbbfdfd011e633cd8e55e7e733078973c428e 100644 (file)
@@ -1,4 +1,6 @@
 use std::io::File;
+use std::io::timer;
+use std::time::Duration;
 
 use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
 use support::{cargo_dir, path2url};
@@ -659,6 +661,9 @@ test!(update_with_shared_deps {
     git_project.process("git").args(["add", "."]).exec_with_output().assert();
     git_project.process("git").args(["commit", "-m", "test"]).exec_with_output()
                .assert();
+
+    timer::sleep(Duration::milliseconds(1000));
+
     assert_that(p.process(cargo_dir().join("cargo-update")).arg("dep1"),
                 execs().with_stdout(format!("{} git repository `{}`",
                                             UPDATING,
@@ -824,6 +829,9 @@ test!(stale_cached_version {
     bar.process("git").args(["add", "."]).exec_with_output().assert();
     bar.process("git").args(["commit", "-m", "test"]).exec_with_output()
        .assert();
+
+    timer::sleep(Duration::milliseconds(1000));
+
     let rev = bar.process("git").args(["rev-parse", "HEAD"])
                  .exec_with_output().assert();
     let rev = String::from_utf8(rev.output).unwrap();